package com.study.train.common.context;

import com.study.train.common.resp.MemberLoginResp;
import lombok.extern.slf4j.Slf4j;

/**
 * @description:
 * @author: ZhangYujie
 * @time: 2025/8/11
 */
@Slf4j
public class LoginMemberContext {
    private static ThreadLocal<MemberLoginResp> threadLocal = new ThreadLocal<>();

    public static void setMember(MemberLoginResp member){
        threadLocal.set(member);
    }

    public static MemberLoginResp getMember(){
        return threadLocal.get();
    }
    public static Long getId(){
        try {
           return threadLocal.get().getId();
        } catch (Exception e) {
            log.error("用户信息获取异常");
        }
        return null;
    }
}
